import {
  UploadFilePageParam,
  FileFolderPageParam,
  FileUserPageParam,
  FileStoragePageParam,  
  FileUserAddParam,
  FileStorageAddParam,
  FileStorageUpdatedParam,
  FileFolderUpdateParam,
  UploadFileUpdatedParam
} from './model/netdiskModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  netdisk = '/plugins/baliServer-module-netdisk/api/netdisk',
  netdiskApi = '/plugins/baliServer-module-netdisk/api',
}

/**
 * 文件
 */
export const getUploadFileList = (params: UploadFilePageParam) =>
  defHttp.get({ url: Api.netdiskApi + '/uploadfile', params }, { isPage: true });
export const deleteUploadFile = (fileId: String) =>
  defHttp.get({
    url: Api.netdisk + '/deleteFile?fileId=' + fileId,
  });
  export const renameUploadFileName = (params?: UploadFileUpdatedParam) =>
  defHttp.post({ url: Api.netdisk + '/updateFileName', params });

/**
 * 文件夹
 */
export const getFileFolderList = (params: FileFolderPageParam) =>
  defHttp.get({ url: Api.netdiskApi + '/filefolder', params }, { isPage: true });
  export const deleteFileFolder = (fileFolderId: String) =>
  defHttp.get({
    url: Api.netdiskApi + '/deleteFileFolder?fileFolderId=' + fileFolderId,
  });
  export const updateFolder = (params?: FileFolderUpdateParam) =>
  defHttp.put({ url: Api.netdiskApi + '/filefolder', params });

/**
 * 文件用户
 */
export const getFileUser = (params: FileUserPageParam) =>
  defHttp.get({ url: Api.netdiskApi + '/fileuser', params }, { isPage: true });
export const addFileUser = (params?: FileUserAddParam) =>
  defHttp.post({ url: Api.netdiskApi + '/fileuser', params });
export const deleteFileUser = (fileUserId: String) =>
  defHttp.delete({
    url: Api.netdiskApi + '/fileuser/' + fileUserId,
  });

/**
 * 文件仓库
 */

export const getFileStorage = (params: FileStoragePageParam) =>
  defHttp.get({ url: Api.netdiskApi + `/filestorage`, params }, { isPage: true });
export const addFileStorage = (params?: FileStorageAddParam) =>
  defHttp.post({ url: Api.netdiskApi + '/filestorage', params });
export const editFileStorage = (params?: FileStorageUpdatedParam & FileStorageAddParam) =>
  defHttp.put({ url: Api.netdiskApi + '/filestorage', params });
export const deleteFileStorage = (fileStorageId: String) =>
  defHttp.delete({
    url: Api.netdiskApi + '/filestorage/' + fileStorageId,
  });

/**
 * 文件夹
 */

/**
 * 公共仓库
 */
export const getPublicStorage = () =>
  defHttp.get({ url: Api.netdisk + '?fileStorageId=00&fileFolderId=00' });
export const downloadFile = (fileId) =>
  defHttp.get({ url: Api.netdisk + '/downloadById?fileId=' + fileId });

// export const addCategory = (params?: CategoryAddParam) =>
//   defHttp.post({ url: Api.category, params });
// export const getCategoryList = (params: CategoryPageParam) =>
//   defHttp.get<CategoryPageListGetResultModel>({ url: Api.category, params }, { isPage: true });
// export const editCategory = (params?: CategoryUpdatedParam & CategoryAddParam) =>
//   defHttp.put({ url: Api.category, params });
// export const deleteCategory = (id: String) =>
//   defHttp.delete({
//     url: Api.category + '/' + id,
//   });
